/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.ana.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lucas.nunes
 */
@Entity
@Table(name = "GEOFT_DNAEE_SUBBACIA")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Subbacia.findAll", query = "SELECT s FROM Subbacia s"),
    @NamedQuery(name = "Subbacia.findByDnsCd", query = "SELECT s FROM Subbacia s WHERE s.dnsCd = :dnsCd"),
    @NamedQuery(name = "Subbacia.findByDnsNm", query = "SELECT s FROM Subbacia s WHERE s.dnsNm = :dnsNm"),
    @NamedQuery(name = "Subbacia.findByDnsGmPoligono", query = "SELECT s FROM Subbacia s WHERE s.dnsGmPoligono = :dnsGmPoligono"),
    @NamedQuery(name = "Subbacia.findByDnsNuSubbacia", query = "SELECT s FROM Subbacia s WHERE s.dnsNuSubbacia = :dnsNuSubbacia")})
public class Subbacia implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "DNS_CD")
    private BigDecimal dnsCd;
    @Size(max = 100)
    @Column(name = "DNS_NM")
    private String dnsNm;
    @Size(max = 4000)
    @Column(name = "DNS_GM_POLIGONO")
    private String dnsGmPoligono;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DNS_NU_SUBBACIA")
    private BigInteger dnsNuSubbacia;
    @OneToMany(mappedBy = "usiDnsCd")
    private List<Usina> usinaList;
    @JoinColumn(name = "DNB_CD", referencedColumnName = "DNB_CD")
    @ManyToOne
    private Bacia dnbCd;
    @OneToMany(mappedBy = "sbrDnsCd")
    private List<SubbaciaRio> subbaciaRioList;

    /**
     *
     */
    public Subbacia() {
    }

    /**
     *
     * @param dnsCd
     */
    public Subbacia(BigDecimal dnsCd) {
        this.dnsCd = dnsCd;
    }

    /**
     *
     * @param dnsCd
     * @param dnsNuSubbacia
     */
    public Subbacia(BigDecimal dnsCd, BigInteger dnsNuSubbacia) {
        this.dnsCd = dnsCd;
        this.dnsNuSubbacia = dnsNuSubbacia;
    }

    /**
     *
     * @return
     */
    public BigDecimal getDnsCd() {
        return dnsCd;
    }

    /**
     *
     * @param dnsCd
     */
    public void setDnsCd(BigDecimal dnsCd) {
        this.dnsCd = dnsCd;
    }

    /**
     *
     * @return
     */
    public String getDnsNm() {
        return dnsNm;
    }

    /**
     *
     * @param dnsNm
     */
    public void setDnsNm(String dnsNm) {
        this.dnsNm = dnsNm;
    }

    /**
     *
     * @return
     */
    public String getDnsGmPoligono() {
        return dnsGmPoligono;
    }

    /**
     *
     * @param dnsGmPoligono
     */
    public void setDnsGmPoligono(String dnsGmPoligono) {
        this.dnsGmPoligono = dnsGmPoligono;
    }

    /**
     *
     * @return
     */
    public BigInteger getDnsNuSubbacia() {
        return dnsNuSubbacia;
    }

    /**
     *
     * @param dnsNuSubbacia
     */
    public void setDnsNuSubbacia(BigInteger dnsNuSubbacia) {
        this.dnsNuSubbacia = dnsNuSubbacia;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<Usina> getUsinaList() {
        return usinaList;
    }

    /**
     *
     * @param usinaList
     */
    public void setUsinaList(List<Usina> usinaList) {
        this.usinaList = usinaList;
    }

    /**
     *
     * @return
     */
    public Bacia getDnbCd() {
        return dnbCd;
    }

    /**
     *
     * @param dnbCd
     */
    public void setDnbCd(Bacia dnbCd) {
        this.dnbCd = dnbCd;
    }

    /**
     *
     * @return
     */
    @XmlTransient
    public List<SubbaciaRio> getSubbaciaRioList() {
        return subbaciaRioList;
    }

    /**
     *
     * @param subbaciaRioList
     */
    public void setSubbaciaRioList(List<SubbaciaRio> subbaciaRioList) {
        this.subbaciaRioList = subbaciaRioList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (dnsCd != null ? dnsCd.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Subbacia)) {
            return false;
        }
        Subbacia other = (Subbacia) object;
        if ((this.dnsCd == null && other.dnsCd != null) || (this.dnsCd != null && !this.dnsCd.equals(other.dnsCd))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.dnsNuSubbacia + " - " + this.dnsNm;
    }
    
}
